#ifndef __USERMANANGER_H__
#define __USERMANANGER_H__

#include "user.hpp"
#include "../include/userStatus.hpp"

#include <iostream>
#include <map>

namespace rocket 
{


class userMananger
{
public:
    static userMananger *get_instance();
    //添加用户对象
    void add_user(int fd,user client);
    //删除用户对象
    void delete_user(int fd);
    //修改用户对象状态
    void modify_user(int fd,userStatus status);
    //获取用户对象指针
    user *get_user(int fd);    
    userMananger(const userMananger &rhs)=delete;
    userMananger &operator=(const userMananger &rhs)=delete;

private:
    userMananger() {}
    ~userMananger() {}
    static void init();
private:
    //存储用户对象的容器
    std::map<int, user>_users;
    //以下为单例自动释放的内容
    class autoRelease
    {
    public:
        ~autoRelease();
    };
    static userMananger *_p_mananger;
    static autoRelease _auto;
    static pthread_once_t _once;

};

}//end of namespace rocket

#endif // __USERMANANGER_H__

